import React, { useState, useEffect } from 'react'
import { Space, Table, message, Tag, Divider } from 'antd';
import axios from 'axios';
export default function DeviceLog() {
  const [dataSource, setDataSource] = useState([])
  const [dataSource1, setDataSource1] = useState([])
  useEffect(() => {
    axios.get("/gatelog/selectall").then(res => {
      setDataSource(res.data)
    })
    // axios.get("/alarm/selectall").then(res => {
    //   setDataSource1(res.data)
    // })
  }, [])
  const columns1 = [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      align: "center",
      fixed: "left",
      width: "5%",
      render: (text, record, index) => {
        return <span style={{ fontSize: "12px" }}>{index + 1}</span>
      }
    },
    {
      title: '告警信息',
      dataIndex: 'alarminfo',
      key: 'alarminfo',
      align: "left",
      fixed: "left",
      render: (text) => {
        return <span style={{ fontSize: "12px" }}>{text}</span>
      }
    },
    {
      title: '告警时间',
      dataIndex: 'alarmtime',
      key: 'alarmtime',
      align: "center",
      render: (text) => {
        return <span style={{ fontSize: "12px" }}>{text}</span>
      }
    }
  ];

  const columns = [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      align: "center",
      width: "10%",
      render: (text, record, index) => {
        return <span style={{ fontSize: "12px" }}>{index + 1}</span>
      }
    },
    {
      title: '操作',
      dataIndex: 'logoperate',
      key: 'operate',
      align: "center",
      render: (text) => {
        return <span style={{ fontSize: "12px" }}>{text}</span>
      }
    },
    {
      title: '访问类型',
      dataIndex: 'htype',
      key: 'htype',
      align: "center",
      render: (text) => {
        return <span style={{ fontSize: "12px" }}>{text}</span>
      }
    },
    {
      title: '内容',
      dataIndex: 'logvalue',
      key: 'logvalue',
      align: "left",
      render: (text) => {
        return <span style={{ fontSize: "12px" }}>{text}</span>
      }
    },
    {
      title: '时间',
      dataIndex: 'logtime',
      key: 'logtime',
      align: "center",
      render: (text) => {
        return <span style={{ fontSize: "12px" }}>{text}</span>
      }
    }
  ];

  return (
    <div >
      {/* <Divider orientation="left" style={{ fontSize: "14px", margin: "0 0 10px 0" }}>告警记录</Divider>
      <Table
        columns={columns} dataSource={data} style={{ margin: "5px 0 0 0" }}
        pagination={{ pageSize: 5 }}
        size='small'
        scroll={{ x: 1200 }}
      >
      </Table> */}
      <Divider orientation="left" style={{ fontSize: "14px", margin: "0 0 10px 0" }}>日志</Divider>
      <Table
        columns={columns} dataSource={dataSource} style={{ margin: "5px 0 0 0" }}
        rowKey={(item) => item.id}
        pagination={{}}
        size='small'
        scroll={{ x: 1200 }}
      >
      </Table>
      {/* <Divider orientation="left" style={{ fontSize: "18px", margin: "15px 0" }}>告警记录</Divider>
      <Table
        columns={columns1} dataSource={dataSource1} style={{ margin: "5px 0 0 0" }}
        rowKey={(item) => item.id}
        pagination={{}}
        size='small'
        scroll={{ x: 1200 }}
      >
      </Table> */}
    </div>
  )
}
